package com.xpert.action.board;

import java.util.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.xpert.action.CommandAction;
import com.xpert.beans.*;
import com.xpert.dao.BoardDao;

public class ListAction implements CommandAction {

    @Override
    public String requestProc(HttpServletRequest request,
    		HttpServletResponse response) throws Throwable {
    	int page = 0;
  	
    	if(request.getParameter("page") != null)
    	    page = Integer.parseInt(request.getParameter("page"));
    
    	ArrayList<Board> articleList = BoardDao.getInstance().getArticleList(page);

    	request.setAttribute("articleList", articleList);
    	request.setAttribute("page", page);
    
    	/*
    	try {
    	    ArrayList<Board> articleList = BoardDao.getInstance().getArticleList(page);
    	    request.setAttribute("articleList", articleList);
    	    request.setAttribute("page", page);
    	}
    	catch(Exception e) {
    	    System.out.println(e.getMessage());
    	    e.printStackTrace();
    	}
    	*/
    
    	return "list.jsp";
    }

}
